package com.aaa.service.impl;

import com.aaa.dao.CountDao;
import com.aaa.dao.impl.CountDaoImpl;
import com.aaa.service.CountService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author ：Teacher陈
 * @date ：Created in 2020/10/31 15:30
 * @description：统计业务接口实现类
 * @modified By：
 * @version: 1.0
 */
public class CountServiceImpl implements CountService {
    CountDao countDao= new CountDaoImpl();
    @Override
    public Map<String, Object> countByEmp() {
        List<Map<String, Object>> mapList = countDao.countByEmp();
        Map<String, Object> map = new HashMap();
        //横坐标，员工姓名数组
        String[] empStrs= new String[mapList.size()];
        //纵坐标1，业务数量数组
        int [] nums = new int[mapList.size()];
        //纵坐标2，业务金额数组
        double[] moneys= new double[mapList.size()];;
        for (int i = 0; i < mapList.size(); i++) {
            Map<String, Object> objectMap = mapList.get(i);
            empStrs[i]=objectMap.get("user_name").toString();
            nums[i]=Integer.parseInt(objectMap.get("total").toString());
            moneys[i]=Double.parseDouble(objectMap.get("money").toString())/10000;
        }
        map.put("empNames",empStrs);
        map.put("nums",nums);
        map.put("moneys",moneys);
        return map;
    }
}
